impl Solution {
    pub fn is_happy(mut n: i32) -> bool {
        let mut n1=n;
        return loop {
            n=Solution::f(n);
            n1=Solution::f(Solution::f(n1));
            if n==1||n1==1{
                break true;
            }
            if n==n1{
                break false;
            }
        }
    }
    fn f(mut n:i32)->i32{
        let mut result=0;
        while n>0{
            let t=n%10;
            result+=t.pow(2);
            n/=10;
        }
        result
    }
}